﻿<UserControl x:Class="Projecturo.ProjecturoClient.View.TicketView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:enums="clr-namespace:Projecturo.Model;assembly=Projecturo.Model"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Height="Auto" Width="Auto">
 
    <UserControl.Resources>
        <ObjectDataProvider x:Key="PriorityProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type Type="{x:Type enums:TicketPriority}"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="TypeProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type Type="{x:Type enums:TicketType}"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
            <Button Command="{Binding DeleteTicketCommand}" Content="Delete"/>
            <Button Command="{Binding SaveCommand}" Content="Save"/>
            <Button Command="{Binding AddNoteCommand}" Content="Add Note"/>
            <Button Command="{Binding AddTimeRecordCommand}" Content="Add Time Record"/>
            <Button Command="{Binding ViewTimeRecordListViewCommand}" Content="View Time Record List"/>
        </StackPanel>
        
            <DockPanel LastChildFill="True" >
                <StackPanel DockPanel.Dock="Left">
                    <TextBlock Text="Name"/>
                    <TextBox Text="{Binding Name}"/>
                    <TextBlock Text="Description"/>
                    <TextBox Text="{Binding Description}" MinLines="5" AcceptsReturn="True" AcceptsTab="True"/>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Column="0" Grid.Row="0" Text="Type" />
                        <ComboBox Grid.Column="1" Grid.Row="0" SelectedItem="{Binding Type}" ItemsSource="{Binding Source={StaticResource TypeProvider}}" />
                        <TextBlock Grid.Column="2" Grid.Row="0" Text="State"/>
                        <ComboBox Grid.Column="3" Grid.Row="0" SelectedValuePath="Id" ItemsSource="{Binding AvailableTicketStates}" SelectedValue="{Binding StateId}"/>
                        <TextBlock Grid.Column="4" Grid.Row="0" Text="Priority"/>
                        <ComboBox Grid.Column="5" Grid.Row="0" SelectedItem="{Binding Priority}" ItemsSource="{Binding Source={StaticResource PriorityProvider}}"/>

                        <TextBlock Grid.Column="0" Grid.Row="1" Text="Assigned To"/>
                        <ComboBox Grid.Column="1" Grid.Row="1" ItemsSource="{Binding Users}" SelectedValuePath="Id" SelectedValue="{Binding AssignedToId}" DisplayMemberPath="ShortName"/>
                        <TextBlock Grid.Column="2" Grid.Row="1" Text="Project"/>
                        <ComboBox Grid.Column="3" Grid.Row="1" ItemsSource="{Binding Projects}" SelectedValuePath="Id" SelectedValue="{Binding Project.Id}" DisplayMemberPath="Name"/>
                        <TextBlock Grid.Column="4" Grid.Row="1" Text="Version"/>
                        <ComboBox Grid.Column="5" Grid.Row="1" ItemsSource="{Binding Versions}" SelectedValuePath="Id" SelectedValue="{Binding VersionId}" DisplayMemberPath="Name"/>

                        <TextBlock Grid.Column="0" Grid.Row="2" Text="Category"/>
                        <ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding Categories}" SelectedValuePath="Id" SelectedValue="{Binding CategoryId}" DisplayMemberPath="Name"/>
                    <TextBlock Grid.Column="2" Grid.Row="2" Text="Milestone"/>
                    <ComboBox Grid.Column="3" Grid.Row="2" ItemsSource="{Binding Milestones}" SelectedValuePath="Id" SelectedValue="{Binding MilestoneId}" DisplayMemberPath="Name"/>

                </Grid>
                <TextBlock Text="Expected Effort in Hours"/>
                <TextBox Text="{Binding ExpectedEffortHours}"/>
                <TextBlock Text="Spent Effort in Hours"/>
                <TextBox Text="{Binding SpentEffortHours,Mode=OneWay}" IsReadOnly="True"/>
                <TextBlock Text="Remaining Effort"/>
                <TextBox Text="{Binding RemainingEffort,Mode=OneWay}" IsReadOnly="True"/>    
            </StackPanel>
                <TextBlock Text="Notes" DockPanel.Dock="Top"/>
                <ListBox ItemsSource="{Binding Notes}" ItemTemplate="{StaticResource NoteListTemplate}" ItemContainerStyle="{StaticResource StretchedContainerStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
            </DockPanel>
        
    </DockPanel>
    
</UserControl>
